pub fn convert_base(num_str: &str, to_base: u32) -> String {
    // 解析输入字符串，格式为 "number(base)"
    let parts: Vec<&str> = num_str.trim_end_matches(')').split('(').collect();
    let num = parts[0];
    let from_base = parts[1].parse::<u32>().unwrap();

    // 先将输入数字转换为10进制
    let mut decimal = 0u32;
    for c in num.chars() {
        let digit = match c {
            '0'..='9' => c as u32 - '0' as u32,
            'a'..='f' => c as u32 - 'a' as u32 + 10,
            'A'..='F' => c as u32 - 'A' as u32 + 10,
            _ => panic!("Invalid digit"),
        };
        decimal = decimal * from_base + digit;
    }

    // 如果目标进制是10，直接返回
    if to_base == 10 {
        return decimal.to_string();
    }

    // 将10进制转换为目标进制
    let mut result = String::new();
    let mut num = decimal;
    while num > 0 {
        let digit = num % to_base;
        let c = match digit {
            0..=9 => (digit as u8 + b'0') as char,
            10..=15 => (digit as u8 - 10 + b'a') as char,
            _ => panic!("Invalid digit"),
        };
        result.insert(0, c);
        num /= to_base;
    }

    // 处理0的情况
    if result.is_empty() {
        result.push('0');
    }

    result
}
